<?php
namespace app\admin\behavior;

use think\Request;
use \think\Config;
use \think\helper\Str;


class Login 
{
    use \traits\controller\Jump;//类里面引入jump;类
    public function run(Request $request, $params)
    {

        // 行为逻辑
        $admin = config()['login_admin'];
        $login = session($admin['auth_uid']);

        //获取当前模块
        $controller=$request->controller();
        $action = $request->action();

        //后台首页
        $url  = Str::lower($controller.DS.$action);
        if($url=='index'.DS.'index'&&!isset($login)){
            $this->redirect(url($admin['user_auth_gateway']));
        }


        //获取无需认证模块配置
        $modules = explode(',',$admin['not_auth_module']);
        if(!in_array(Str::lower($controller),$modules)&&!isset($login)){
            $this->redirect(url($admin['user_auth_gateway']));
        }
    }
}